import requests
import json


class DetailApi:

    def __init__(self):
        pass

    def detail(self, token, appId):
        headers = {
            "User-Agent": "RestSharp/107.3.0.0",
            "Accept": "application/json, text/json, text/x-json, text/javascript, application/xml, text/xml",
            "timezone": "%2b08%3a00",
            "ipv4": "192.168.43.133",
            "Accept-Language": "zh-CN,zh;q=1",
            "Authorization": f"bearer {token}"
        }
        url = "https://api.winrobot360.com/api/client/app/develop/app/detail"
        params = {
            "appId": appId,
            "heckAppRecycle": "True"
        }
        response = requests.get(url, headers=headers, params=params)

        # Format and print JSON response with indentation
        try:
            json_data = response.json()
            formatted_json = json.dumps(json_data, indent=4, ensure_ascii=False)
            print(formatted_json)

            return json_data
        except json.JSONDecodeError:
            print("Response is not valid JSON:")
            print(response.text)

        print(response)


if __name__ == '__main__':
    token = '37e87789-9c8a-4fdd-a121-df69a6f5af6b'
    appId = '42951364-bfb0-4e65-83ec-a63dc3c1adfc'
    detailApi = DetailApi()
    detailApiInfo = detailApi.detail(token, appId)
